<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="/WEB-INF/tlds/spring.tld"%>
<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld"%>
<c:set var="BasePath" value="${pageContext.request.contextPath}"></c:set>
<c:set var="Plugins" value="${pageContext.request.contextPath}/res/plugins"></c:set>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>供应链权限列表</title>
<link href="${BasePath}/res/css/common/liger-hack.css" rel="stylesheet" type="text/css" />
<link href="${Plugins}/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<script src="${Plugins}/jquery/jquery-1.3.2.min.js"	type="text/javascript"></script>
<script src="${Plugins}/ligerUI/js/core/base.js" type="text/javascript"></script>
<script src="${Plugins}/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<link href="${BasePath}/res/css/common/base.css" rel="stylesheet" type="text/css" />
<script src="${Plugins}/jquery-validation/jquery.validate.js" type="text/javascript"></script>
<script src="${BasePath}/res/js/common/jquery.validate.method.js" type="text/javascript"></script>
<script src="${Plugins}/jquery-validation/jquery.metadata.js" type="text/javascript"></script>
<script src="${Plugins}/jquery-validation/messages_cn.js" type="text/javascript"></script>
<script src="${BasePath}/res/js/common/jquery.form.js" type="text/javascript"></script>
<script src="${Plugins}/ligerUI/js/plugins/ligerTree.js" type="text/javascript"></script>
<script src="${Plugins}/ligerUI/js/plugins/ligerTip.js" type="text/javascript"></script>
<script type="text/javascript" src="${BasePath}/res/js/role/role.js"></script>
<style type="text/css">
#searchbar{
	margin-bottom: 10px;
}
.navbar {
		height: 20px;
		border-bottom: #E6E6E6 solid 1px;
		line-height: 20px;
	}
.s-button {
	width:50px; margin-left:10px; padding-bottom:2px;
}
.yt-form-btn-back {
width: 72px;
height: 24px;
line-height: 24px;
margin-left: 5px;
background: url(../../../res/images/access/reset-btn.gif) no-repeat;
color: #6A6A6A;
border: 0px;
letter-spacing: 3px;
font-weight: bold;
cursor: pointer;
}
.l-table-edit {}
.l-table-edit-td{ padding:4px;}
.l-button-submit,.l-button-cancel{width:80px; float:left; margin-left:10px; padding-bottom:2px;}
.l-verify-tip{ left:230px; top:120px;}
</style>
<script type="text/javascript">
    var manager = null;
    var checkedMenuStructures = new Array();
    $(".l-tree .l-body span").live('mouseover', function (e) {
        if (!this.title) 
            this.title = $(this).text();
    });

    $(function () {
    	$("#tree1").ligerTree({
            url: 'ajaxLoadAccessTree.do?roleId=' + $('#id').val(),  
            nodeWidth : 400
        });
        manager = $("#tree1").ligerGetTreeManager();
    });
    </script>
</head>
<body style="padding:10px"> 
	<div id="">
		<div class="navbar"><span>您当前的位置： 系统管理&gt; 供应链角色管理 &gt; 分配权限</span></div>
		<br/>
	</div>
    <div style="width:400px; height:500px; margin:10px; float:left; border:1px solid #ccc; overflow:auto;  ">
    <ul id="tree1">
    </ul> 
    </div>
    <div>
    	<form action="allocateAccess.do" id="allocateAccessForm" name="allocateAccessForm" method="post">
			 <input type="hidden" id="id" name="id" value="${roleVo.id }">
			 <input type="hidden" id="menuStructures" name="menuStructures" value="">
			 <div class="ytweb-form-btn" style="margin-top: 540px;">
				<input type="submit" value="提交" class="yt-form-btn-back" style="margin-top: 10"/>
				<input type="button" value="取消" class="yt-form-btn-back" onclick="javascript:cancelAllocateAccess();"/>
	         </div>
		</form>
    </div>
<script type="text/javascript">
$(function() {
	//validate
    $.metadata.setType("attr", "validate");
    var v = $("form").validate({
        errorPlacement: function (lable, element)
        {
            if (element.hasClass("l-textarea"))
            {
            	lable.ligerHideTip();
                element.ligerTip({ content: lable.html(), target: element[0] }); 
            }
            else if (element.hasClass("l-text-field"))
            {
            	lable.ligerHideTip();
                element.parent().ligerTip({ content: lable.html(), target: element[0] });
            }
            else
            {
                lable.appendTo(element.parents("td:first").next("td"));
            }
        },        
        success: function (lable)
        {
            lable.ligerHideTip();
            lable.remove();
        },
        submitHandler:function()
        {
        	var menuStructures = manager.getChecked();
        	for (var i=0; i<menuStructures.length; i++) {
        		checkedMenuStructures.push(menuStructures[i].data.structure);
        	}
        	$('#menuStructures').val(checkedMenuStructures);
            $("form .l-text,.l-textarea").ligerHideTip();
            var options = {
            		type: 'POST',
            		success: function(data){
            			if(data == "success") {
            				var s =window.parent.$.ligerDialog.success("分配成功","提示",function () {
            	        		parent.window.location.reload();
            	        	});
            	        	$(s.dialog.winbtns).remove();
            			} else {
            				window.parent.$.ligerDialog.error("分配失败");
            			}
            		}
            	}, $form1 = $("#allocateAccessForm");
            $form1.ajaxSubmit(options);
            return false;
        }
    });
	$("form").ligerForm();
});
</script>
</body>
</html>